require 'digest/md5'

class User < ActiveRecord::Base

  before_save { |user| user.mail = mail.downcase }

  VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
  validates :mail, presence:   true,
                    format:     { with: VALID_EMAIL_REGEX },
                    uniqueness: { case_sensitive: false }
  validates :password, presence: true, length: { minimum: 6 }
  validates :first_name, presence: true, length: { minimum: 2}
  validates :last_name, presence: true, length: { minimum: 2}
	has_one :user_info
	has_many :user_mails
	has_many :user_rating
	has_many :items
	attr_accessible :first_name, :inscription_date, :last_login, :last_name, :mail, :password
end
